﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Rendiciones.Logica.Extensiones
{
    public enum DateInterval
    {
        Day,
        Hour,
        Minute,
        Second,
    }

    public class DateTimeExtension
    {
        public static int DateDiff(DateInterval interval, DateTime date1, DateTime date2)
        {
            double rs = 0;

            var diff = date2.Subtract(date1);
            switch (interval)
            {
                case DateInterval.Day:
                    rs = diff.Days;
                    break;
                case DateInterval.Hour:
                    rs = diff.Hours;
                    break;
                case DateInterval.Minute:
                    rs = diff.Minutes;
                    break;
                case DateInterval.Second:
                    rs = diff.Seconds;
                    break;
            }
            var @int = (int)rs;
            return @int;
        }
    }
}